const {ccclass} = cc._decorator

import Simulation from "../lockStep/Simulation";
import SimulationManager from "../lockStep/SimulationManager";
import Entity from "./Entity";

/// 根据Component数据，来执行渲染
@ccclass
export default class IRenderer extends cc.Component
{
    entityId:string ="";
    simulation:Simulation = null;

    SetEntityId(entityId:string)
    {
        this.entityId = entityId;
    }

    // lifecycle callback
    start()
    {
        // this.simulation = SimulationManager.Instance().GetSimulation("123");
    }

    update(dt)
    {
        if(this.entityId === null || this.entityId === "") return;
        let entity  = this.simulation.GetEntityWorld().GetEntity(this.entityId);
        if (entity === null) return;
        if (!entity.isActive) return;
        this.OnRender(entity, dt);                     
    }

    // 子类需要实现的方法
    OnRender(entity:Entity, dt:number):void 
    {

    }
}